﻿package src.utils 
{
	import flash.display.LoaderInfo;
	import flash.display.MovieClip;
	import src.data.ConfigData;
	import src.debug.MonsterDebugger;
	import src.player.StageSetup;
	
	/**
	 * ...
	 * @author hrh - 2009
	 */
	
	public class FlashVars extends MovieClip
	{
		private var config:ConfigData;
		private var sta:StageSetup;
		private var exist:Boolean = false;
		
		public function FlashVars(st:StageSetup,conf:ConfigData) 
		{
			sta = st;
			config = conf;
			
			getVars();
		}
		
		public function get exisist():Boolean
		{
			return exist;
		}
		
		private function getVars():void
		{
			
			try 
			{			
				var keyStr:String;
				var valueStr:String;
				var paramObj:Object = LoaderInfo(sta.root.loaderInfo).parameters;   
				
				
			} 
			catch (e:Error) 
			{
				MonsterDebugger.trace(this, "file." + e.message);
			}
			
			for (keyStr in paramObj) 
			{		
				valueStr = String(paramObj[keyStr]);
				
				switch (keyStr)
				{
					case "feed" :							
					config.baseurl = valueStr;
					MonsterDebugger.trace(this, "file." + config.baseurl);
					break;
					
					case "id" :	
					config.id = int(valueStr);
					MonsterDebugger.trace(this, "id: " + config.id);
					break;	
					
					case "autoplay" :
					config.autostart = Boolean(valueStr);					
					break;	
					
					case "resources" :
					//config.resources = valueStr;
					break;
					
					case "visitor" :
					config.visitor = valueStr;
					MonsterDebugger.trace(this, "visitor: " + config.visitor );
					break;
					
					case "session" :
					config.session = valueStr
					MonsterDebugger.trace(this, "session id " + config.session);
					break;
					
					default:	
					trace("default no flashvars");
					
				}
			}
		}	
	}
}